import {
    left as threecolumns_left,
    center as threecolumns_center,
    body as threecolumns_body,
    grid as threecolumns_grid,
    center_top as threecolumns_center_top,
} from '@/css/layout/ThreeColumns.module.scss' ;

import {
    button,
    search,
    itemInfo,
    girdHeader,
    center_header,
    formTitle,
    contact_header,
} from '@/css/VueCss.module.scss' ;
export default {
    title: '客户管理',
    order: 1,
    layout:'three-columns',
    items:[{
        region:'left',
        class:threecolumns_left,
        layout: 'vertical',
        items: [{
            id: 'search',
            class: search,
            widget: 'search',
            text:{
                field: 'keywords',
                placeholder: '请输入客户(公司)'
            },
            onSearch: [{
                action:'grid-load',
                target:'$widgets.grid',
                params:'$params'
            }]
        },{
            layout: 'horizontal',
            class: contact_header,
            items:[{
                class: formTitle,
                id: 'title',
                widget: 'public-title',
                title: '客户(公司)',
            },{
                class: button,
                widget: 'buttonicon',
                type: 'text',
                layout: 'horizontal',
                onClick: [{
                    action:'dialog-show',
                    path: 'Customer/CustomerList/Edit',
                    params: {
                        title:"'新增客户'"
                    },
                    applyActions: [{
                        action: 'call',
                        target: '$widgets.grid',
                        method: 'reload'
                    }],
                    cancelActions: [{
                        action: 'print',
                        description: '取消对话框'
                    }]
                }]
            }]
        },{
            id:'grid',
            widget:'grid',
            service:'crm/customer/list',
            pageSize:20,
            columns:[{
                prop:'name',
            }],
            flex:true,
            header:false,
            enableIndexColumn: false,
            operationButtonCount: 0,
            operationWidth: 30,
            buttons: [{
                value: '编辑',
                onClick: [{
                    action: 'dialog-show',
                    path: 'Customer/CustomerList/Edit',
                    params: {
                        title:"'编辑客户信息'",
                        form: '$params',
                    },
                    applyActions: [{
                        action: 'call',
                        target: '$widgets.grid',
                        method: 'reload'
                    }],
                    cancelActions: [{
                        action: 'print',
                        description: '取消对话框'
                    }]
                }]
            },{
                value: '删除',
                type: 'danger',
                onClick: [{
                    action: 'confirm',
                    title: '删除数据',
                    message: '是否删除该条数据?',
                    confirm: [{
                        action: 'service',
                        path: 'crm/customer/remove',
                        params: {
                            id: '$params.id'
                        }
                    }, {
                        action: 'call',
                        target: '$widget',
                        method: 'reload'
                    }]
                }]
            }],
            onRowselect:[{
                action:'print',
                value:'$params'
            },{
                action:'form-value',
                target:'$widgets.formbasic',
                value:'$params'
            },{
                action:'grid-load',
                target:'$widgets.gridContacts',
                service:'crm/contacts/list',
                params:{
                    customer_uuid: "$params.uuid"
                }
            },{
                action:'grid-load',
                target:'$widgets.gridLogs',
                service: 'crm/potential/record/list',
                params:{
                    type: 2,
                    customer_uuid: "$params.uuid"
                }
            },{
                action:'grid-load',
                target:'$widgets.gridContract',
                service:'crm/contract/list',
                params:{
                    customer_uuid: "$params.uuid"
                }
            }],
        }]
    },{
        region:'center',
        items:[{
            class:threecolumns_center_top,
            items:[{
                layout: 'horizontal',
                flex: true,
                class: center_header,
                items:[{
                    id: 'title',
                    widget: 'public-title',
                    title: '基础信息',
                    width:100
                },{
                    id: 'tags',
                    widget: 'data-tags',
                    addVisible: true,
                    addSize: 'small',
                    value: [{
                        type: 'success',
                        value: '客户标签1',
                        size: 'default',
                        closable: true,
                    }],
                },{
                    class: button,
                    widget: 'button',
                    value: '编辑',
                    layout: 'horizontal',
                    onClick: [{
                        action:'dialog-show',
                        path:'Customer/CustomerList/Edit',
                        params:{
                            form:'$widgets.grid.selectedItem',
                            title:'"编辑客户信息"'
                        },
                        applyActions: [{
                            action: 'call',
                            target: '$widgets.grid',
                            method: 'reload'
                        },{
                            action: 'call',
                            target: '$widgets.formbasic',
                            method: 'setValue',
                            params: '$params'
                        }],
                        cancelActions: [{
                            action: 'print',
                            description: '取消对话框'
                        }]
                    }]
                },{
                    class: button,
                    widget: 'button',
                    type: 'primary',
                    value: '详情',
                    layout: 'horizontal',
                    onClick: [{
                        action:'dialog-show',
                        path:'Customer/Manage/CustomerDetails',
                        params:{
                            form:'$widgets.grid.selectedItem',
                            title:'"客户详情"'
                        },
                        applyActions: [{
                            action: 'call',
                            target: '$widgets.formbasic',
                            method: 'reload'
                        },{
                            action: 'call',
                            target: '$widgets.formbasic',
                            method: 'setValue',
                            params: '$params'
                        }],
                        cancelActions: [{
                            action: 'print',
                            description: '取消对话框'
                        }]
                    }]
                }]
            },{
                class: itemInfo,
                id:'formbasic',
                widget:'form',
                dictionary:'crm/customer/list',
                layout: 'gridform',
                fields:[{
                    itemId:'name',
                    widget:'form-text',
                    label:'客户名称',
                },{
                    itemId:'industry_uuid',
                    widget:'select',
                    print:true,
                    dictionary: {
                        path: 'common/dictionary/config',
                        params: {
                            name: 'crm_customer_industry',
                        },
                    },
                    label:'所属行业',
                },{
                    itemId:'source_uuid',
                    widget:'select',
                    print:true,
                    dictionary: {
                        path: 'common/dictionary/config',
                        params: {
                            name: 'crm_customer_source',
                        },
                    },
                    label:'客户来源',
                },{
                    itemId:'stage_uuid',
                    widget:'select',
                    print:true,
                    dictionary: {
                        path: 'common/dictionary/config',
                        params: {
                            name: 'crm_sale_stage',
                        },
                    },
                    label:'当前阶段',
                },{
                    itemId:'salesman',
                    widget:'form-text',
                    label:'销售联系人',
                },{
                    itemId:'contact',
                    widget:'form-text',
                    label:'客户联系人',
                },{
                    itemId:'phone',
                    widget:'form-text',
                    label:'手机号码',
                },{
                    itemId: 'last_follow_time',
                    widget:'form-text',
                    label:'最近联系',
                },{
                    itemId:'contents',
                    widget:'form-text',
                    label:'沟通内容',
                }],
                flex:true,
            }]
        },{
            flex:1,
            class:[threecolumns_center, threecolumns_body],
            layout:'tab',
            items:[{
                title:'客户联系人',
                layout:'vertical',
                items:[{
                    items:[{
                        class: girdHeader,
                        items:[{
                            class: button,
                            widget: 'button',
                            value: '新增',
                            onClick: [{
                                action:'dialog-show',
                                path:'Customer/Manage/ContactsEdit',
                                params: {
                                    title:"'新增客户联系人'",
                                    form: {
                                        customer_uuid:'$widgets.grid.selectedItem.uuid'
                                    }
                                },
                                applyActions: [{
                                    action: 'call',
                                    target: '$widgets.gridContacts',
                                    method: 'reload'
                                }],
                                cancelActions:[{
                                    action:'print',
                                    description:'取消对话框'
                                }]
                            }]
                        }]
                    }]
                },{
                    class: threecolumns_grid,
                    id: 'gridContacts',
                    widget: 'grid',
                    pageSize: 20,
                    columns:[{
                        prop:'name',
                        label:'联系人',
                        width: 220
                    },{
                        prop:'position_uuid',
                        dictionary: {
                            path: 'common/dictionary/config',
                            params: {
                                name: 'crm_customer_position',
                            },
                        },
                        label:'职位',
                    },{
                        prop:'phone',
                        label:'手机号码',
                    },{
                        prop:'last_follow_time',
                        label:'最后联系',
                    }],
                    buttons:[{
                        value:'编辑',
                        onClick:[{
                            action:'dialog-show',
                            path:'Customer/Manage/ContactsEdit',
                            // params: '$params',
                            params: {
                                title:"'编辑联系人信息'",
                                form: '$params',
                            },
                            applyActions: [{
                                action: 'call',
                                target: '$widgets.gridContacts',
                                method: 'reload'
                            }],
                            cancelActions:[{
                                action:'print',
                                description:'取消对话框'
                            }]
                        }]
                    },{
                        value:'详情',
                        onClick:[{
                            action:'dialog-show',
                            path:'Customer/Contacts/InfoDetails',
                            params: '$params',
                        }]
                    },{
                        value:'删除',
                        type:'danger',
                        onClick:[{
                            action:'confirm',
                            title:'删除数据',
                            message:'是否删除该条数据?',
                            confirm:[{
                                action:'service',
                                path:'crm/contacts/remove',
                                params: {
                                    id: '$params.id'
                                }
                            },{
                                action: 'call',
                                target: '$widget',
                                method: 'reload'
                            }]
                        }]
                    },{
                        value:'跟进',
                        onClick:[{
                            action:'dialog-show',
                            path:'Customer/Contacts/FollowUp',
                            params: {
                                title:"'跟进'",
                                form: '$params',
                            },
                            applyActions: [{
                                action: 'call',
                                target: '$widgets.gridContacts',
                                method: 'reload'
                            }],
                            cancelActions:[{
                                action:'print',
                                description:'取消对话框'
                            }]
                        }]
                    }],
                    flex: true,
                    operationWidth: 105,
                }]
            },{
                title:'跟进记录',
                layout:'vertical',
                items:[{
                    items:[{
                        class: girdHeader,
                        items:[{
                            id: 'search',
                            class: search,
                            widget: 'search',
                            onSearch: [{
                                action:'grid-load',
                                target:'$widgets.gridLogs',
                                params: {
                                    type: 2,
                                    customer_uuid: "$widgets.grid.selectedItem.uuid",
                                    page_size: '$widgets.gridLogs.pageSize',
                                    keywords: '$params.keywords',
                                }
                            }]
                        }]
                    }]
                },{
                    class: threecolumns_grid,
                    id: 'gridLogs',
                    widget: 'grid',
                    pageSize: 20,
                    columns:[{
                        prop:'create_time',
                        label:'最近联系时间',
                        with: 180
                    },{
                        prop:'salesman_uuid',
                        label:'销售员',
                        dictionary: 'common/dictionary/salesman',
                    },{
                        prop:'contact',
                        label:'客户联系人',
                    },{
                        prop:'phone',
                        label:'手机号码',
                    },{
                        prop:'contents',
                        label:'内容',
                    },{
                        prop:'update_time',
                        label:'下次跟进时间',
                        with: 180
                    }],
                    flex: true,
                    enableEdit:true,
                }]
            },{
                title:'合同列表',
                layout:'vertical',
                items:[{
                    items:[{
                        class: girdHeader,
                        items:[{
                            class: button,
                            widget: 'button',
                            value: '新增',
                            layout: 'horizontal',
                            onClick: [{
                                action:'dialog-show',
                                path:'Customer/Manage/ContractEdit',
                                params: {
                                    title:"'新增客户合同'",
                                    form: {
                                        customer_uuid:'$widgets.grid.selectedItem.uuid'
                                    }
                                },
                                applyActions: [{
                                    action: 'call',
                                    target: '$widgets.gridContract',
                                    method: 'reload'
                                }],
                                cancelActions:[{
                                    action:'print',
                                    description:'取消对话框'
                                }]
                            }]
                        }]
                    }]
                },{
                    class: threecolumns_grid,
                    id:'gridContract',
                    widget:'grid',
                    pageSize:20,
                    columns:[{
                        prop:'code',
                        label:'合同编号',
                        minWidth: 200
                    },{
                        prop:'name',
                        label:'合同名称',
                        minWidth: 200
                    },{
                        prop:'sign_time',
                        label:'签订时间',
                        width: 200
                    },{
                        prop:'status_uuid',
                        label:'合同状态',
                        dictionary: {
                            path: 'common/dictionary/config',
                            params: {
                                name: 'crm_contract_status',
                            },
                        },
                        width: 120
                    }],
                    buttons:[{
                        value:'编辑',
                        onClick:[{
                            action:'dialog-show',
                            path:'Customer/Manage/ContractEdit',
                            params: {
                                title:"'编辑合同信息'",
                                form: '$params',
                            },
                            applyActions:[{
                                action:'call',
                                target:'$widgets.gridContract',
                                method:'reload'
                            }],
                            cancelActions:[{
                                action:'print',
                                description:'取消对话框'
                            }]
                        }]
                    },{
                        value:'详情',
                        onClick:[{
                            action:'dialog-show',
                            path:'Contract/Details',
                            params: '$params',
                        }]
                    },{
                        value:'删除',
                        type:'danger',
                        onClick:[{
                            action:'confirm',
                            title:'删除数据',
                            message:'是否删除该条数据?',
                            confirm:[{
                                action:'service',
                                path:'crm/contract/remove',
                                params: {
                                    id:'$params.id'
                                }
                            },{
                                action:'call',
                                target:'$widget',
                                method:'reload'
                            }]
                        }]
                    }],
                    flex:true,
                    operationWidth:130,
                    operationButtonCount:3,
                }]
            }]
        }]
    }],
} ;
